package com.hotel.mapper;

import com.hotel.pojo.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper {
    // 查询所有管理员信息
    @Select("select * from admin")
    List<Admin> findAllAdmin();

    // 新增管理员
    @Insert("insert into admin(name, username, password) values(#{name}, #{username}, #{password})")
    void addAdmin(Admin admin);

    // 查看管理员是否存在
    @Select("select * from admin where name = #{name}")
    Admin findAdminByName(String name);

    // 更新管理员信息
    @Update("update admin set username=#{username}, password=#{password} where name = #{name}")
    void updateAdmin(Admin admin);

    // 删除管理员
    @Delete("delete from admin where name = #{name}")
    void deleteAdmin(Admin admin);

    // 登陆
    @Update("update admin set status=1 where name=#{name}")
    void loginAdmin(String name);

    // 注销
    @Update(("update admin set status=0 where name=#{name}"))
    void exitAdmin(String name);

    // 查看登录状态
    @Select("select status from admin where name=#{name}")
    int isLogin(String name);
}
